
import std.stdio;
import std.exception;

class ErrorCodeHelper
{
enum ErrorCode : uint{
        ParamesError = 62000,
        SignError = 62001,
        TokenError = 62002,
        UserError = 62003,
        CodeError = 62004,
        Argument    = 61000,
        ExistUser   = 61001,
        NotExistUser    = 61002,
        PasswdError     = 61003,
        PasswdNotSame   = 61004,
        ExistPhone      = 61005,
        TimeOut         = 61006,
        NoPremission    = 61007,
        WrongVerify     = 61008,
        PhoneIsEmpty    = 61009,
        WrongNumber     = 61010,
        MailIsEmpty     = 61011,
        WrongMail       = 61012,
        PasswordTooLongOrTooShort = 61013,
        HandleFailed    = 61014,
        RemindExpire        = 61015,
        SamePhoneNum    = 61016,
        ExistEmail      = 61017,
        IllegalNickName = 61018,
        NickNameExist   = 61019,
        AppidError      = 61020,
        RefreshTokenError = 61021,
        Unknow          = 61022,
        ExistDeviceId   = 61023,
        ServeridError   = 61024,
        NetworkError    = 61025,
        IllegalFrom      = 60101,
        TooManyTimes     = 60103,
        NotSetupPasswd   = 60304,
        BeautyNumberExist = 60305,
        BeautyNumberNotExist = 60306,
        LoginErrorFiveTimes  = 60307,
        UserNotBind = 60308,
        IsNotAdmin = 60309,
        IsAlreadyAdmin       = 60310,
        IsAlreadyReset       = 60311,
        BirthdayError        = 60312,
        BirthdayNotSet       = 60313,
        HeightNotSet         = 60314,
};
}

mixin template ExceptionBuild(string name, string parent = "")
{
	enum buildStr = "class " ~ name ~ "Exception : " ~ parent ~ "Exception { \n\t" ~ "mixin basicExceptionCtors;\n }";
	mixin(buildStr);
}

pragma(inline, true)
void throwExceptionBuild(string name = "", string file = __FILE__, size_t line = __LINE__ )(string msg)
{
	mixin("throw new " ~ name ~ "Exception(msg,\"" ~ file ~ "\"," ~ line.stringof ~ ");");
}

string buildErroCodeException(T)()
{
    string str = "mixin ExceptionBuild!(\"ErrorCode\");\n";
    foreach(memberName; __traits(derivedMembers,T))
    {
        str ~= "mixin ExceptionBuild!(\"" ~ memberName ~ "\", \"ErrorCode\");\n";
      
    }
    return str;
}

void main()
{
    writeln(buildErroCodeException!(ErrorCodeHelper.ErrorCode)());
}

mixin(buildErroCodeException!(ErrorCodeHelper.ErrorCode)())
